<?php
error_reporting(0);
$isadmin=1;
include_once '../comm/config.php';
include '../comm/checkpostandget.php';
include '../comm/msgset.php';
include 'check.php';
$ddusername=$_POST['ddusername']; 
$txje=$_POST['txje']; 
$id=$_POST['id']; 
$link = mysql_connect($dbserver, $dbuser, $dbpass);
if (!$link) {
     die(ERR_DB);
}
mysql_select_db($dbname);
mysql_query("set names utf8");

$q = "select * from ".$BIAOTOU."tixian where Id=".$id;
$rs=mysql_query($q);
$num = mysql_num_rows($rs);
if(!$num)
{
	echo "错误：未找到该记录！";
	exit;
}
else
{
	while ($row = mysql_fetch_array($rs))
	{
		$zfb=$row["zfb"]; }
	$q = "update ".$BIAOTOU."tixian set txstate=1 where id=".$id;
	mysql_query($q);
	
	$q = "update ".$BIAOTOU."user set money=money-".$txje.",txstate=0,yitixian=yitixian+".$txje." where ddusername='$ddusername'";
	mysql_query($q);

	$sj= date("Y-m-d H:i:s");  
	$title="您有一笔提现申请已经受理完成";
	$msg_tixianok=str_replace("[ddusername]",$ddusername,$msg_tixianok);
	$msg_tixianok=str_replace("[txje]",$txje,$msg_tixianok);
	$msg_tixianok=str_replace("[zfb]",$zfb,$msg_tixianok);
	$insert = "INSERT into ".$BIAOTOU."msg(ddusername,title,content,addtime,senduser) values ('$ddusername','$title','$msg_tixianok','$sj','网站客服')";
	mysql_query($insert);
	$insert = "INSERT into ".$BIAOTOU."mingxi(ddusername,shijian,je,addtime,memo) values ('$ddusername','提现成功',-$txje,'$sj','支付宝帐号".$zfb."')";
	mysql_query($insert);
}   

header('Location: tixianlist.php');
mysql_close($link);

?>
